#include "../Base/stdafx.h"
#include "Counter.h"

Counter::Counter(): m_StartTime(0), m_EndTime(0)
{

}

Counter::~Counter()
{

}

void Counter::Start()
{
	m_StartTime = timeGetTime();
}

void Counter::Stop()
{
	m_EndTime = timeGetTime();
}

tstring Counter::GetTime()
{
	tstringstream buffer;
	if(m_EndTime == 0)
		buffer << (timeGetTime() - m_StartTime);
	else
		buffer << (m_EndTime - m_StartTime);
	
	return buffer.str();
}

tstring Counter::GetTimeBig()
{
	tstringstream buffer;
	int dif;
	if(m_EndTime == 0)
		dif = timeGetTime() - m_StartTime;
	else
		dif = m_EndTime - m_StartTime;

	dif /= 1000;
	int hour = dif / 3600;
	int minute = (dif / 60) - (hour * 60);
	int seconde = dif - (hour * 3600) - (minute * 60);

	if(hour < 10) buffer << _T("0");
	buffer << hour << _T(":");
	if(minute < 10) buffer << _T("0");
	buffer << minute << _T(":");
	if(seconde < 10) buffer << _T("0");
	buffer << seconde;
	
	return buffer.str();
}